<!doctype html>
<html>
<head>
    <title>{$INI['system']['sitename']} {$city['name']}</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="/css/style.css">
    <link rel="stylesheet" href="/css/font-awesome.min-4.3.0.css">
	<script src="/js/jsAddress.js" type="text/javascript"></script>
	<script src="/js/jquery.min-2.1.3.js" type="text/javascript"></script>
</head>

<body>
<!--{if $session_notice=Session::Get('error',true)}-->
<script>
alert('{$session_notice}');
</script>
<!--{/if}-->
	
    <div id="c_paipai.buyOne_show">
        <div class="wx_wrap">
			<!--{if $order['address']==''}-->
			<div id="addr_html">
				<div id="sendTo">
					 <div class="address address_defalut" id="addAddr">
						<h4>您还没有收货地址哦，点击新增地址</h4>
					 </div>
				</div>
			</div>
			<!--{else}-->
            <a class="send_address" href="/account/setaddress.php?refurl={$refurl}">
                <div id="sendTo">
                    <div class="address address_defalut">
                        <h3>送至</h3>
                        <ul id="editAddBtn" class="selected">
                            <li>{$order['address']}</li>
                            <li><strong>{$order['realname']}&nbsp;{$order['mobile']}</strong></li>
                        </ul>
                    </div>
					<!--
                    <div class="address address_defalut">
                        <h4>您还没有收货地址哦，点击新增地址</h4>
                    </div>
					-->
                </div>
            </a>
			<!--{/if}-->
            <div class="order">
                <div class="order_bd">
                    <div id="orderList" class="order_glist">
                        <div class="only">
                            <div class="order_goods">
                                <div class="order_goods_img">
                                    <img alt="" src="${team_image($team['image'])}">
                                </div>
                                <div class="order_goods_info">
                                    <div class="order_goods_name"><span id="tuanLbl"></span>{$team['title']}</div>
                                    <div class="order_goods_attr">
                                        <div class="order_goods_attr_item">
                                            <span class="order_goods_attr_tit">数量：</span>
                                            <div class="order_goods_num">{$order['quantity']}</div>
                                            <div id="goodsPrice" class="order_goods_price">${moneyit($order['price'])}<i>/件</i></div>
                                        </div> 
                                        <p class="order_goods_attr_item">库存：<span id="skuLast">{$team['max_number']}</span><i>件</i></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
				
            <div id="pay_area" style="opacity: 1;">
                <div class="total"><!--{if $team['delivery']=='express'}-->快递：¥${($team['farefree']==0||$order['quantity']<$team['farefree'])?$order['fare']:0}<!--{/if}--> 
				总价：<span id="totalPrice" rel="{$order['origin']}" class="total_price"><!--{if !empty($first_card)}-->${$order['origin']-$first_card['credit']}<!--{else}-->{$order['origin']}<!--{/if}--></span></div>
                <div class="pay2">
                    <div class="pay2_hd">请选择支付方式</div>
                    <div id="payList" class="pay2_list">
                        <div id="goTenPay" class="pay2_item pay2_wx pay2_selected">
                            <span class="pay2_item_state"></span>
                            <span class="pay2_item_ico"></span>
                            <span class="pay2_item_tit">微信支付</span>
                        </div>
						
						<!--{if !empty($first_card)}-->
						<div id="goBonus" class="item pay3_item pay2_selected">
                            <span class="pay2_item_state"></span>
                            <span class="pay3_item_ico"></span>
                            <span class="pay3_item_tit">红包券&nbsp;
							<!--{if !empty($first_card)}-->
							<font id="quan_money">{$first_card['credit']}</font>元红包券
							<!--{/if}-->
							</span>
							<span class="tip_jpt"></span>
                        </div>
						<div class="pay3_list" id="pay3_list">
							<div class="pay3_box">
								<div class="coup_tip">当前可用</div>
								
								<!--{loop $cards_list $index $one}-->
								<div class="coup_one" rel="{$one['id']}" r_money="{$one['credit']}">
									<img src="/images/liofis_quan.jpg" class="coup_img" />
									<div class="coup_tit">{$INI['system']['sitename']}</div>
									<div class="coup_text_left1">
										<b>{$one['credit']}元红包券</b>
										<div class="text_copus_desc1">
										优质水果，新鲜直送～</div>
									</div>
									<div class="coup_time_right1">
										<b>有效期</b>
										<div class="text_copus_time1">
										${date('Y-m-d',$one['begin_time'])}<br>${date('Y-m-d',$one['end_time'])}
										</div>
									</div>
								</div>
								<!--{/loop}-->
								
							</div>
							<style>
							.pay3_item{display:block;}
							</style>
						</div>
						<!--{/if}-->
						
                    </div>
                    <form action="/order/pay.php" method="post" class="validator">
                        <div>
							<input type="hidden" name="order_id" value="{$order['id']}"  />
							<!--{if $cards_list}-->
							<input type="hidden" name="card_id" id="card_id" value="{$first_card['id']}" />
							<!--{/if}-->
							
							<input type="hidden" name="paytype" value="wxpay"  />
                            <input type="submit" name="submit" value="立即支付" class="pay2_btn" id="btn_order_done" />
                            <input type="hidden" name="step" value="done" />
                            <input type="hidden" id="sku_event_id" name="sku_event_id" />
                            <input type="hidden" id="group_order_id" name="group_order_id" />
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="step">
            <div class="step_hd">
                拼团玩法<a class="step_more" href="/help/zuitu.php">查看详情</a>
            </div>
            <div id="footItem" class="step_list">
                <div class="step_item">
                    <div class="step_num">1</div>
                    <div class="step_detail">
                        <p class="step_tit">选择
                            <br>心仪商品</p>
                    </div>
                </div>
                <div class="step_item step_item_on">
                    <div class="step_num">2</div>
                    <div class="step_detail">
                        <p class="step_tit">支付开团
                            <br>或参团</p>
                    </div>
                </div>
                <div class="step_item">
                    <div class="step_num">3</div>
                    <div class="step_detail">
                        <p class="step_tit">邀请好友
                            <br>参团支付</p>
                    </div>
                </div>
                <div class="step_item">
                    <div class="step_num">4</div>
                    <div class="step_detail">
                        <p class="step_tit">达到人数
                            <br>团购成功</p>
                    </div>
                </div>
            </div>
        </div>
		<div id="address" style="display:none;">
			<div class="address_new">
				<form id="myForm">
					<h3>收货地址</h3>
					<p>
						<label for="name"><span class="tit">收货人</span>
							<input id="name" name="name" value="" placeholder="名字" type="text">
						</label>
					</p>
					
					<p>
						<label for="mobile"><span class="tit">联系电话</span>
							<input id="mobile" name="mobile" value="" placeholder="手机或固号" type="tel">
						</label>
					</p>
					<p>
						<span class="tit">选择地区</span>
						<select id="selProvinceList"  name="province"></select>
						<select id="selCityList" name="city" ></select>
						<select id="selTownList" name="town"></select>
					</p>
					<p>
						<label for="adinfo"><span class="tit">详细地址</span>
							<input id="adinfo" name="adinfo" value="" placeholder="街道门牌信息" type="text">
						</label>
					</p>
					<p style="display:none;">
						<label for="zipcode"><span class="tit">邮政编码</span>
							<input id="zipcode" name="zipcode" value="" placeholder="邮政编码（选填）" type="text">
						</label>
					</p>
					<p class="action">
						<button type="button" class="submit"  id="add">确认</button>
					</p>
				</form>
			</div>
		</div>
    </div>
	<style>
	#address {  
		  position: absolute;
		  width: 100%;
		  background-color: #fff;
		  bottom: 0px;
		  padding: 10px;
	 }
	.address_new p {
		border-bottom: 1px solid #cbcbcb;
		padding: 10px 20px 10px 100px;
		position: relative;
	}

	.address_new .tit {
		bottom: 0;
		color: #666;
		height: 20px;
		left: 0;
		line-height: 20px;
		margin: auto 0;
		padding-right: 20px;
		position: absolute;
		right: 0;
		text-align: right;
		top: 0;
		width: 80px;
	}

	.address_new input {
		border: 1px solid #ddd;
		box-sizing: border-box;
		color: #333;
		font-size: 14px;
		height: 35px;
		line-height: 25px;
		padding: 0 5px;
		vertical-align: top;
		width: 100%;
	}

	.address_new select {
		background: url("") no-repeat scroll right center/15px 5px #fff;
		border: 1px solid #ddd;
		font-size: 14px;
		height: 35px;
		line-height: 35px;
		padding: 0 16px 0 5px;
		position: relative;
		width: 100%;
	}

	.address_new select option {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.address_new button {
		background-color: #3884ff;
		border: 0 none;
		border-radius: 2px;
		color: #fff;
		display: block;
		font-size: 16px;
		height: 40px;
		line-height: 40px;
		margin-bottom: 10px;
		width: 100%;
	}

	.address_new .area {
		padding: 5px 0;
	}

	.address_new .area label {
		display: block;
		padding: 5px 20px 5px 100px;
		position: relative;
	}

	.address_new .area .error {
		background-color: rgba(255,0,0,.2);
	}

	.address_new .action {
		border-bottom: 0 none;
		padding: 15px 10px;
	}

	.address_new .submit {
		background-color: #3985ff;
	}
	</style>
	<script>
	var areacondlimit ={$is_js_arealimit};
	var arealimitprovince = '{$cityname}';
	
	<!--{if $order['address'] ==''}-->
	var can_addr_sub = false;
	<!--{else}-->
	var can_addr_sub = true;
	<!--{/if}-->
	var  or_id = "{$order['id']}";
	var is_show_bonus = false;
	$(document).ready(function(){
	
		$('.coup_one').click(function(){
			var rel = $(this).attr('rel');
			var r_money = $(this).attr('r_money')
			
			
			$('#card_id').val(rel);
			$('#quan_money').html(r_money);
			var orip = $('#totalPrice').attr('rel');
			
			$('#totalPrice').html(  (parseFloat(orip)-parseFloat(r_money)).toFixed(2) );
			if(is_show_bonus)
			{
				$('#goBonus').removeClass('pay3_selected');
				is_show_bonus = false;
			} else {
				$('#goBonus').addClass('pay3_selected');
				is_show_bonus = true;
			}
			$('#pay3_list').toggle();
		})
		$('#goBonus').click(function(){
			if(is_show_bonus)
			{
				$(this).removeClass('pay3_selected');
				is_show_bonus = false;
			} else {
				$(this).addClass('pay3_selected');
				is_show_bonus = true;
			}
			$('#pay3_list').toggle();
		
		})
		//card_id
		setTimeout("hidetip()",3000);
		$('#btn_order_done').click(function(){
			if(!can_addr_sub)
			{
				$('#address').show()
				addressInit('selProvinceList', 'selCityList', 'selTownList');		
				return false;
			}
		})
		$('#addAddr').click(function(){
			$('#address').show()
			addressInit('selProvinceList', 'selCityList', 'selTownList');	
		})
		$('#add').bind('click',function(){
			var name = $.trim($('#name').val());
			var mobile = $.trim($('#mobile').val());
			var adinfo = $.trim($('#adinfo').val());
			
			var province = $('#selProvinceList').val();
			var city = $('#selCityList').val();
			var area = $('#selTownList').val();
			
			//<select id="selProvinceList"  name="province"></select>
			//<select id="selCityList" name="city" ></select>
			//<select id="selTownList" name="town"></select>
						
			if(name == '')
			{
				alert('姓名不能为空');
				return false;
			}	
			if(mobile == '')
			{
				alert('手机号不能为空');
				return false;
			}
			if(!mobile.match('^1[3|5|8|7][0-9]{9}$')){ alert("请输入正确的手机号码！");return false; }
			
			if(area == '市辖区')
			{
				alert('请选择具体的区县');
				return false;
			}
			if(adinfo == '')
			{
				alert('详细地址不能为空');
				return false;
			}
			
			
			
			var addr_ajax = '/ajax/account.php';
			var a_data = {name:name,mobile:mobile,adinfo:adinfo,province:province,city:city,area:area,order_id:or_id};
			
			$.ajax({
				url:addr_ajax,
				type:'post',
				dataType:'json',
				data:a_data,
				success:function(res){
					if(res.state)
					{
						var addr_html = '';
						addr_html += '<div id="sendTo">';
						addr_html += '	<div class="address address_defalut">';
						addr_html += '		<h3>送至</h3>';
						addr_html += '		<ul id="editAddBtn" class="selected">';
						addr_html += '			<li>'+province+city+area+adinfo+'</li>';
						addr_html += '			<li><strong>'+name+'&nbsp;'+mobile+'</strong></li>';
						addr_html += '		</ul>';
						addr_html += '	</div>';
						addr_html += '</div>';
						$('#addr_html').html(addr_html);
						$('#address').hide();	
						location.href = location.href;
						return false;
					} else {
						alert('提交失败');
					}
				}
			})
			
			return false;
		})
	}); 
	function hidetip() 
	{ 
		$('#sysmsg-error').fadeOut();
	}
	</script>
